package com.example.library_demo.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.library_demo.entity.Book;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.library_demo.vo.book.BookInfoVO;
import com.example.library_demo.vo.book.BookVO;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author Eric
 * @since 2024-11-27
 */
public interface BookMapper extends BaseMapper<Book> {

    @Select("select * from l_book where status = 1")
    IPage<BookVO> selectPageAll(Page page);

    @Select("select * from l_shelf s left join l_book b on s.shelf_id = b.shelf_id where s.shelf_status = 1 and s.shelf_id = #{shelfId} and b.status = 1;")
    List<BookInfoVO> selectBooksByShelfId(long shelfId);

    @Select("select * from l_book where status = 0")
    IPage<BookVO> selectStorageBook(Page page);

}
